
class Pessoa {

    String nome
    Date dtCadastro
    Date dtUAcesso
    Date dtUAtualizacao
    String status = 0
    String password
    String username
    String banco
    String ag
    String cc
    boolean enabled = true
    boolean accountExpired = false
    boolean accountLocked = false
    boolean passwordExpired = false

    static mapping = {
        tablePerHierarchy false;
    }

    static hasMany = [ contato:Contato, endereco:Endereco ]

    static constraints = {
        nome(size: 1..100, blank: false)
        username(size: 1..60, blank: false)
        password(blank: false,minSize: 6)
        banco(size: 0..60)
        ag(size: 0..10)
        cc(size: 0..20)
        status(size: 1..1, blank: false)
        dtCadastro(nullable: true)
        dtUAcesso(nullable: true)
        dtUAtualizacao(nullable: true)       
    }

    String toString() {
        return "${id}" 
    }

    Set<Role> getAuthorities() {
		PessoaRole.findAllByPessoa(this).collect { it.role } as Set
	}
}
